package com.android.lovepick;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.android.lovepick.util.BaseUtils;

public class MainActivity extends Activity
{
	private Button btnLogin;
	private Button btnReg;
	private Button btnTest;

	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		// getActionBar().setDisplayHomeAsUpEnabled(true);
		findView();
		setListener();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu)
	{
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item)
	{
		switch (item.getItemId())
		{
			case android.R.id.home:
				NavUtils.navigateUpFromSameTask(this);
				return true;
		}
		return super.onOptionsItemSelected(item);
	}

	private void findView()
	{
		btnLogin = (Button) this.findViewById(R.id.main_btn_login);
		btnReg = (Button) this.findViewById(R.id.main_btn_reg);
		btnTest = (Button) this.findViewById(R.id.main_btn_test);
		// this.findViewById(R.id.main_btn_order);
	}

	private void setListener()
	{
		btnLogin.setOnClickListener(loginListener);
		btnReg.setOnClickListener(regListener);
		btnTest.setOnClickListener(testListener);
	}

	private View.OnClickListener loginListener = new View.OnClickListener()
	{

		public void onClick(View v)
		{
			// TODO Auto-generated method stub
			Intent intent = new Intent(MainActivity.this, LoginActivity.class);
			startActivity(intent);
		}
	};

	private OnClickListener regListener = new View.OnClickListener()
	{

		public void onClick(View v)
		{
			// TODO Auto-generated method stub
			Intent intent = new Intent(MainActivity.this, RegActivity.class);
			startActivity(intent);
		}
	};

	private OnClickListener testListener = new View.OnClickListener()
	{

		public void onClick(View v)
		{
			// TODO Auto-generated method stub
			Intent intent = new Intent(MainActivity.this, TestActivity.class);
			startActivity(intent);
		}
	};

	public void toOrder(View v)
	{
		Intent intent = new Intent(MainActivity.this, OrderActivity.class);
		startActivity(intent);
	}

	public void exit(View v)
	{
		BaseUtils.exit(this);
	}

}
